package com.hkd.system.controller.question;



import com.hkd.common.core.domain.R;
import com.hkd.common.core.domain.TableDataInfo;
import com.hkd.system.domain.question.dto.QuestionAddDTO;
import com.hkd.system.domain.question.dto.QuestionEditDTO;
import com.hkd.system.domain.question.dto.QuestionQueryDTO;
import com.hkd.system.service.question.IQuestionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Slf4j
@RestController
@RequestMapping("/question")
@Tag(name = "题目管理")
public class QuestionController {

    @Autowired
    private IQuestionService questionService;

    /**
     * 分页查询题目列表
     * @param questionQueryDTO 返回前端分页查询
     * @return TableDataInfo
     */
    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO){
        return questionService.list(questionQueryDTO);
    }

    /**
     * 新增题目
     * @param questionAddDTO 题目信息
     * @return R
     */
    @PostMapping("/add")
    public R add(@RequestBody QuestionAddDTO questionAddDTO){
        return questionService.add(questionAddDTO);
    }
    @GetMapping("/detail")
    public R detail(Long questionId){
        return questionService.detail(questionId);
    }

    @PutMapping("/edit")
    public R edit(@RequestBody QuestionEditDTO questionEditDTO){
        return questionService.edit(questionEditDTO);
    }
    @DeleteMapping("/delete")
    public R delete(Long questionId){
        return questionService.delete(questionId);
    }
}
